package com.yanqu.road.server.cmd.cross.union;

import com.yanqu.road.entity.union.cross.CrossUnionInfo;
import com.yanqu.road.pb.union.UnionProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.manger.CrossUnionServerGroupMgr;
import com.yanqu.road.server.manger.config.UnionConfigMgr;
import com.yanqu.road.server.manger.union.CrossUnionMgr;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_CROSS_TO_QUERY_UNION_RESP, desc = "跨服拜访商会响应")
public class CrossWatchUnionRespCmd extends AbstractCommand {

	@Override
	public boolean parseData(YanQuMessage packet) throws Exception {
		return true;
	}

	@Override
	public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
		UnionProto.CrossUnionQueryFromServerRespMsg reqMsg = UnionProto.CrossUnionQueryFromServerRespMsg.parseFrom(packet.getBytes());
		UnionProto.CrossUnionQueryRespMsg.Builder respMsg = UnionProto.CrossUnionQueryRespMsg.newBuilder();
		respMsg.setRet(ret);
		if(0 == ret) {
			respMsg.setServerId(reqMsg.getServerId());
			respMsg.setUnion(reqMsg.getUnion());
			respMsg.setMaxMemberCount(reqMsg.getMaxMemberCount());

			for (UnionProto.UnionMemberTempMsg temp : reqMsg.getMemberListList()) {
				respMsg.addMemberList(temp);
			}
		}
		player.sendPacket(Protocol.U_CROSS_UNION_QUERY, respMsg);
	}

	@Override
	public void sendData(GamePlayer player) {

	}
}
